package com.cal.utms.core;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class MenuItemAction extends ActionSupport implements ModelDriven<MenuItemDto>, SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private MenuItemDto menuItemDto = new MenuItemDto();
	MenuModel menuModel = new MenuModel();
	private Map<String, Object> session;

	public String getMainMenu() {
		menuItemDto.setMenuItemDtos(menuModel.getMainMenu());
		return Action.SUCCESS;
	}

	public String getMenuByUserGroup() {
		menuItemDto.setMenuItemDtos(menuModel.getScreenByGroupId((Integer) session.get("userGroup")));
		return Action.SUCCESS;
	}

	@Override
	public MenuItemDto getModel() {
		return menuItemDto;
	}

	public MenuItemDto getMenuItemDto() {
		return menuItemDto;
	}

	public void setMenuItemDto(MenuItemDto menuItemDto) {
		this.menuItemDto = menuItemDto;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;

	}

}
